package com.tour.controller;


import com.tour.config.ResponseWrapper;
import com.tour.entity.Targets;
import com.tour.service.impl.TargetsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lel
 * @since 2020-12-30
 */
@Api(tags = "认领贫困对象管理")
@RestController
@RequestMapping("/app/targets")
public class TargetsController {

    @Autowired
    TargetsServiceImpl targetsService;

    @ApiOperation("认领贫困对象")
    @PostMapping("/addTargets")
    public ResponseWrapper addTargets(@RequestBody Targets targets){
        ResponseWrapper wrapper = targetsService.addTargets(targets);
        return wrapper;
    }

    @ApiOperation("查询捐助过的所有贫困对象")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId",value = "用户的id"),
            @ApiImplicitParam(name = "pageSize",value = "每页展示的数据条数",defaultValue = "10"),
            @ApiImplicitParam(name = "pageNum",value = "页码数",defaultValue = "1")
    })
    @GetMapping("/findAllTargets")
    public ResponseWrapper findAllTargets(@RequestParam(name = "userId")Integer userId,
                                          @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
                                          @RequestParam(name = "pageNum",defaultValue = "1")Integer pageNum){
        ResponseWrapper wrapper = targetsService.findAllTargets(userId,pageSize,pageNum);
        return wrapper;

    }

}

